/**
 * 订单相关接口类型定义
 */

// 通用响应结构
export interface ApiResponse<T = any> {
  code: number;
  msg: string;
  time: string;
  data: T;
}

// 用户信息
export interface UserInfo {
  id: number;
  name: string;
}

// 商品扩展信息
export interface GoodsExtend {
  goods_name_length: string;
  goods_name_pinyin: string;
  status: string;
  goods_id: string;
  mini_type: string;
}

// 买家存单请求参数
export interface GetMaijiaCarqudanReq {
  maijia_id?: number;
  keywords?: string;
}

// 买家存单单个项目
export interface CarqudanItem {
  id: number;
  maijia_id: number;
  name: string;
  admin_id: number;
  guadan: string;
  time: string;
  shouyin_id: number;
  car_num: number;
  order_id: number | null;
  type: number;
  sort: number;
  total_price: number;
  order_car: OrderCarItem[];
  user: UserInfo;
}

// 订单商品项目
export interface OrderCarItem {
  id: number;
  car_id: number;
  maijia: string;
  maijia_id: number;
  price: number;
  maijia_num: number;
  huozhu_num: number;
  add_time: string;
  extend: GoodsExtend;
  fujiafei: number | null;
  fujiafei_before: number | null;
  fujiafei_num: number;
  fujiafei_weight: number;
  goods_fujiafei: GoodsFujiafeiItem[];
  goods_id: number;
  goods_name: string;
  goods_price: number;
  goods_price_before: number;
  goods_price_lr: number;
  note: string | null;
  num: number;
  num_multiple: number;
  pici: string | null;
  pici_id: number;
  shouyin_id: number;
  status: number;
  store_id: number;
  time: number;
  total_price: number;
  unit: string;
  weight: number;
  weight_multiple: number;
  mini_type: string;
  mini_type_num: number;
}

// 商品附加费项目
export interface GoodsFujiafeiItem {
  id: number;
  name: string;
  price: number;
  total: number;
  num?: number;
  weight?: number;
  type?: string;
  unit?: string;
}

// 编辑信息
export interface EditInfo {
  editUsername: string;
  editUsernameId: number;
}

// 添加订单数据请求
export interface AddOrderDataReq {
  alipay_num: number;
  cash_num: number;
  discount_num: string;
  editInfo: EditInfo;
  heji: number;
  input_num: string;
  notes: string;
  orderCarData: OrderCarItem[];
  order_id: string;
  other_num: number;
  qudancenterToAccountList: OrderCarItem[];
  shishou: number;
  status: number;
  time: string;
  union_num: number;
  value: number;
  wepay_num: number;
  yingshou: number;
}

// 买家存单响应数据
export type GetMaijiaCarqudanRes = ApiResponse<CarqudanItem[]>;

// 添加订单结算响应数据
export type AddOrderDataRes = ApiResponse;

// 收银列表请求参数
export interface DataCarReq {
  page?: number;
  limit?: number;
  keyword?: string;
  status?: number;
}

// 收银列表响应数据
export type DataCarRes = ApiResponse<{
  count: number;
  list: CarqudanItem[];
}>;

// 获取买家车请求参数
export interface GetMaijiaCarReq {
  maijia_id: number;
}

// 删除车请求参数
export interface DeleteCarReq {
  id: number;
}

// 挂单数据请求参数
export interface GuadanDataReq {
  car_list: number[];
  maijia_id: number;
  guadan: string;
}

// 添加买家车请求参数
export interface AddMaijiaCarReq {
  maijia_id: number;
  goods_id: number;
  goods_name: string;
  num: number;
  weight: number;
  price: number;
  unit: string;
  mini_type?: string;
  mini_type_num?: number;
}

// 添加买家车响应数据
export interface AddMaijiaCarRes extends ApiResponse<{
  car_id: number;
  maijia_id: number;
  name: string;
}> { }

// 获取买家车响应数据
export interface GetMaijiaCarRes extends ApiResponse<{
  data: Array<{
    id: number;
    name: string;
    maijia_id: number;
    admin_id?: number;
    guadan?: string | null;
    time?: string;
    shouyin_id?: number;
    car_num?: number;
    order_id?: number | null;
    type?: number;
    sort?: number | null;
    maijia?: {
      id: number;
      username: string;
    };
  }>;
  qudanNum: number;
}> { }

// DataCar响应数据具体定义
export interface DataCarGoodsRes extends ApiResponse<{
  data: OrderCarItem[];
}> { }

// 删除车响应数据
export interface DeleteCarRes extends ApiResponse<{
  success: boolean;
}> { }

// 挂单数据响应
export interface GuadanDataRes extends ApiResponse<{
  success: boolean;
}> { }

// 获取订单数据请求参数
export interface GetOrderDataReq {
  keywords?: string;
  maijia_id?: number;
  status?: number;
  date?: string[];
  page?: number;
  limit?: number;
}

// 获取订单数据响应
export interface GetOrderDataRes extends ApiResponse<{
  data: OrderCarItem[];
  total?: number;
  per_page?: number;
  current_page?: number;
  last_page?: number;
}> { }

/** 还款请求参数 */
export interface HuankuanDataReq {
  /** 订单ID数组 */
  order_id: number[];
  /** 买家ID */
  maijia_id: number;
  /** 备注 */
  notes: string;
  /** 现金支付金额 */
  cash_num: number;
  /** 合计金额 */
  heji: string;
  /** 实收金额 */
  shishou: string;
  /** 微信支付金额 */
  wepay_num: number;
  /** 支付宝支付金额 */
  alipay_num: number;
  /** 银联支付金额 */
  union_num: number;
  /** 其他支付金额 */
  other_num: number;
  /** 输入金额 */
  input_num: string;
  /** 折扣金额 */
  discount_num: number;
  /** 值 */
  value: number;
  /** 应收金额 */
  yingshou: string;
}

/** 还款响应结果 */
export interface HuankuanDataRes extends ApiResponse<{
  /** 订单信息 */
  order?: {
    /** 订单ID */
    id: number;
    /** 订单状态 */
    status: number;
    /** 支付时间 */
    pay_time: string;
    /** 支付金额 */
    pay_amount: string;
  };
  /** 操作是否成功 */
  success: boolean;
  /** 返回的消息 */
  message?: string;
}> { }

/** 商品列表查询请求参数 */
export interface GetGoodsListReq {
  /** 商品名称 */
  goods_name: string;
  /** 索引 */
  index: number;
  /** 每页数量 */
  limit: number;
  /** 页码 */
  page: number;
  /** 批次ID */
  pici_id: number;
  /** 销售状态 */
  saleStatus: number;
}

// 商品规格接口
export interface GoodsGuige {
  id: number;
  goods_id: number;
  name: string;
  num: number;
  unit: string;
  relation: string;
  shouyin_id: number;
  add_num?: number;
}

// 商品附加费接口
export interface GoodsFujiafeiDetail {
  id: number;
  goods_id: number;
  name: string;
  rate: number;
  type: string;
  type_name: string;
  method: string;
  method_name: string;
  shouyin_id: number;
  time: string;
  template_id: number;
  total: number;
}

// 批次信息接口
export interface PiciInfo {
  id: number;
  huozhu_id: number;
  huozhu_name: string;
  shouyin_id: number;
  admin_id: number;
  time: string;
  add_time: number;
  license: string;
  bind: number;
  pici: number;
  status: number;
  sell_out_time: null | string;
  settle_time: null | string;
  delete_time: null | string;
  huozhu?: {
    id: number;
    lxr_name: string;
    last_login_time: null | string;
    lxr_tel: string;
    phone: null | string;
    token: null | string;
    dp_name: string;
    amount: string;
    dp_logo: string;
    dp_top_img: string;
    brief: string;
    notice: null | string;
    is_gys_type: number;
    gl_user: number;
    remark: string;
    post_time: string;
    peisong_time_later: string;
    free_post: string;
    post_fee: string;
    is_goods_audit: number;
    is_goods_edit_audit: number;
    set_printer: number;
    is_printer_tel: number;
    order_voice_prompt: number;
    yly_params: null | string;
    fey_params: null | string;
    is_list: number;
    list_num: number;
    status: number;
    is_on_shop: number;
    is_on_cart: number;
    shop_time: null | string;
    add_time: number;
    supplier_desensitization: number;
    admin_id: number;
    shouyin_id: number;
  };
}

// 类别信息接口
export interface CategoryInfo {
  id: number;
  name: string;
}

// 附加费明细接口
export interface FujiafeiItem {
  id: number;
  name: string;
  total: string;
}

// 商品详情接口
export interface GoodsItem {
  goods_name_length: number;
  goods_name_pinyin: string;
  status: number;
  goods_id: number;
  mini_type: string;
  is_desk: number;
  pici_id: number;
  goods_name: string;
  sell_type: string;
  store_count_dot: string;
  sell_num: number;
  sell_weight: number;
  goods_barcode: null | string;
  goods_number: null | string;
  market_price: string;
  is_scantling: number;
  cat_id: number;
  pici: PiciInfo;
  cat_id_2: null | number;
  cat_id_3: number;
  store_count: string;
  desk_price: string;
  original_img: string;
  is_guige: number;
  unit: string;
  desk_vip_discount: null | string;
  weight: string;
  weight_type: number;
  settlement_id: number;
  average_weight: string;
  mini_type_num: string;
  huan: string;
  no_pay: string;
  sell_str: string;
  sell_str_length: number;
  store_count_str: string;
  store_count_dot_str: string;
  fujiafei: FujiafeiItem[];
  single: string;
  single_length: number;
  all_goods_price: string;
  all_total_price: string;
  sell_weight_unit: number;
  sell_num_unit: number;
  fujia_weight_unit: number;
  fujia_num_unit: number;
  weight_unit_expand: number;
  fujiafei_weight_unit: string;
  num_unit_expand: number;
  fujiafei_num_unit: string;
  goods_spec: any[];
  goods_guige: GoodsGuige[];
  goods_fujiafei: GoodsFujiafeiDetail[];
  cat_one: CategoryInfo | null;
  cat_two: CategoryInfo | null;
  pici_info: PiciInfo;
  goodsGuige: GoodsGuige[];
  goodsFujiafei: GoodsFujiafeiDetail[];
}

// 列表统计信息接口
export interface ListStats {
  total_num: string;
  total_weight: string;
  sell_total_num: string;
  sell_total_weight: string;
  inventory_num: string;
  inventory_weight: string;
  total_huan: string;
  total_no_pay: string;
  end_time: string;
  start_time: string;
  single: string;
  goods_total: string;
  all_average_weight: string;
}

// 费用项接口
export interface FeiyongxiangItem {
  id: number;
  book_id: number;
  set_id: string;
  name: string;
  money: number;
  add_time: string;
  shouyin_id: number;
  pay_type: number;
  admin_id: number;
  type: number;
  pici_id: number;
  notes: string;
  settlement_id: number;
  delete_time: null | string;
  pid: number;
  username: string;
}

// 商品总计接口
export interface GoodsTotal {
  all_goods_price: string;
  all_total_price: string;
  fujiafeidetail: { total: string }[];
}

// 附加费设置接口
export interface FujiafeiSetItem {
  id: number;
  name: string;
  rate: number;
  type: string;
  method: string;
  shouyin_id: number;
  time: string;
  admin_id: number;
  total: number;
}

// 商品列表响应数据
export interface GetGoodsListRes extends ApiResponse<{
  data: {
    total: number;
    per_page: number;
    current_page: number;
    last_page: number;
    data: GoodsItem[];
  };
  list: ListStats;
  list_exist: number;
  letters: string[];
  feiyongxiang: FeiyongxiangItem[];
  goods_total: GoodsTotal;
  feiyongxiangTotal: number;
  jiesuanTotal: string;
  fujiafeiSet: FujiafeiSetItem[];
  settlement_list: any[];
  settlement_total: string;
}> { }

/** 批次支出数据请求参数 */
export interface AddPiciZhichuDataReq {
  /** 金额 */
  money: string;
  /** 名称 */
  name: string;
  /** 名称ID */
  name_id: number;
  /** 备注 */
  notes: string;
  /** 支付类型 */
  pay_type: number;
  /** 批次ID */
  pici_id: number;
  /** 类型 */
  type: string;
}

/** 批次支出数据响应 */
export interface AddPiciZhichuDataRes extends ApiResponse<{
  success: boolean;
}> { }

/** 获取分类商品请求参数 */
export interface GetSelfCategoryGoodsReq {
  /** 键值 */
  key: number;
  /** 是否新批次 */
  new_pici: boolean;
  /** 绑定值 */
  bind: string;
  /** 最后批次ID */
  last_pici_id: string;
  /** 批次ID */
  pici_id: number;
  /** 索引 */
  index: number;
  /** 页码 */
  page: number;
  /** 每页数量 */
  limit: number;
  /** 商品名称 */
  goods_name: string;
}

/** 商品存在信息 */
export interface GoodsExist {
  goods_id: number;
  goods_self: number;
  supplier_id: number;
  fujiafei: null;
  over_inventory: string;
  store_count_dot: number;
  store_count: number;
  sell_num: number;
  sell_weight: number;
  sell_type: string;
  mini_type: string;
  unit: string;
  goods_name_pinyin: string;
  goods_name: string;
  chinese_letter: string;
  pici: number;
  pici_id: number;
  py_code: string;
  status: number;
  is_guige: number;
  goods_number: null;
  goods_barcode: null;
  goods_remark: null;
  goods_key_words: string;
  item_no: string;
  cat_id: number;
  cat_id_2: null;
  cat_id_3: number;
  is_fenxiao: number;
  fx_tgfl: null;
  fx_zgfl: null;
  low_buy: number;
  weight: string;
  weight_type: number;
  market_price: string;
  shop_price: string;
  desk_price: string;
  huiyuan_price: null;
  cost_price: string;
  lately_price: string;
  goods_content: null;
  original_img: string;
  is_real: number;
  is_on_sale: number;
  on_time: number;
  sort: number;
  is_recommend: number;
  is_new: number;
  is_choose: number;
  is_hot: number;
  exchange_score: number;
  exchange_integral: number;
  sales_sum: number;
  prom_type: number;
  prom_id: number;
  commission: string;
  cat_list: string;
  ed_time: number;
  is_score: number;
  is_ticket: number;
  is_rob: number;
  news: null;
  rob_limit: number;
  collect_num: number;
  images: null;
  is_share: number;
  post_fee: string;
  goods_detail: string;
  detail_image: string;
  only_post: number;
  is_delete: number;
  update_time: string;
  yu_jianjie: string;
  own_zt_time: string;
  zt_time: number;
  bm: string;
  spec_id: string;
  add_time: string;
  home_nav: number;
  is_market: number;
  is_tejia: number;
  tag: number;
  rob_price: string;
  activity_front: number;
  activity_after: number;
  discount: string;
  weight_unit_id: number;
  video_from: string;
  video: null;
  is_pre_sale: number;
  set_sku_type: string;
  bottom_ads: string;
  top_left_tag: number;
  exchang_num: number;
  person_limit_single: number;
  person_limit_sum: number;
  pre_sale_num: number;
  sales_sum_xn: number;
  share_title: string;
  share_img: string;
  gys_is_sh: number;
  gys_sh_reason: null;
  supp_is_list: number;
  supp_list_num: number;
  gs: string;
  ct_type: number;
  synch_time: null;
  is_scantling: number;
  rack_ids: null;
  source_area: string;
  cai_id: number;
  cai_type: number;
  factory: string;
  report_id: number;
  is_desk: number;
  desk_vip_discount: null;
  revenueCode: null;
  taxRate: null;
  taxation_category: null;
  warehouse_stock: string;
  procure_upper: string;
  walker_floor: string;
  walker_upper: string;
  stock_upper: string;
  stock_floor: string;
  sale_stock_floor: string;
  alias_name: string;
  sellby_date: number;
  producer: string;
  loss_rate: string;
  brand: string;
  subcat_id: string;
  subcat_id_2: string;
  subcat_id_3: string;
  produce_date: null;
  sellby_date_end: null;
  admin_id: number;
  shouyin_id: number;
  delete_time: null;
}

/** 分类商品项 */
export interface CategoryGoodsItem {
  status: number;
  goods_id: number;
  mini_type: string;
  is_desk: number;
  pici_id: null;
  goods_name: string;
  sell_type: string;
  store_count_dot: number;
  sell_num: number;
  sell_weight: number;
  goods_barcode: null;
  goods_number: null;
  market_price: string;
  is_scantling: number;
  cat_id: number;
  pici: null;
  cat_id_2: number | null;
  cat_id_3: number;
  store_count: number;
  desk_price: string;
  original_img: string;
  is_guige: number;
  unit: string;
  desk_vip_discount: null;
  weight: string;
  weight_type: number;
  goods_exist: GoodsExist | string;
  has_been_add: boolean;
  name1?: boolean;
  goods_guige: GoodsGuige[];
  goods_fujiafei: GoodsFujiafeiDetail[];
}

/** 分类商品列表响应 */
export interface GetSelfCategoryGoodsRes extends ApiResponse<{
  data: {
    total: number;
    per_page: number;
    current_page: number;
    last_page: number;
    data: CategoryGoodsItem[];
  };
}> { }
